import { getUserById as getUserByIdApi } from '@/api/user' // 用户接口

export default {
  namespaced: true,
  // 数据源
  state: () => ({
    user: JSON.parse(localStorage.getItem('user')) || {}
  }),
  mutations: {
    // 获取用户信息
    async setUser(state, user) {
      const result = await getUserByIdApi(user.id)
      state.user = result.data[0]
      localStorage.setItem('user', JSON.stringify(result.data[0]))
    }
  },
  actions: {}
}
